home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / libgimp / gimpproceduraldb_pdb.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-26  |  12.0 KB  |  426 lines

  1. /* LIBGIMP - The GIMP Library
  2.  * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
  3.  *
  4.  * gimpproceduraldb_pdb.c
  5.  *
  6.  * This library is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU Lesser General Public
  8.  * License as published by the Free Software Foundation; either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * This library is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  * Lesser General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU Lesser General Public
  17.  * License along with this library; if not, write to the
  18.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19.  * Boston, MA 02111-1307, USA.
  20.  */
  21.  
  22. /* NOTE: This file is autogenerated by pdbgen.pl */
  23.  
  24. #include <string.h>
  25.  
  26. #include "gimp.h"
  27.  
  28. /**
  29.  * gimp_procedural_db_dump:
  30.  * @filename: The dump filename.
  31.  *
  32.  * Dumps the current contents of the procedural database
  33.  *
  34.  * This procedure dumps the contents of the procedural database to the
  35.  * specified file. The file will contain all of the information
  36.  * provided for each registered procedure. This file is in a format
  37.  * appropriate for use with the supplied \"pdb_self_doc.el\" Elisp
  38.  * script, which generates a texinfo document.
  39.  *
  40.  * Returns: TRUE on success.
  41.  */
  42. gboolean
  43. gimp_procedural_db_dump (gchar *filename)
  44. {
  45.   GimpParam *return_vals;
  46.   gint nreturn_vals;
  47.   gboolean success = TRUE;
  48.  
  49.   return_vals = gimp_run_procedure ("gimp_procedural_db_dump",
  50.                     &nreturn_vals,
  51.                     GIMP_PDB_STRING, filename,
  52.                     GIMP_PDB_END);
  53.  
  54.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  55.  
  56.   gimp_destroy_params (return_vals, nreturn_vals);
  57.  
  58.   return success;
  59. }
  60.  
  61. /**
  62.  * gimp_procedural_db_query:
  63.  * @name: The regex for procedure name.
  64.  * @blurb: The regex for procedure blurb.
  65.  * @help: The regex for procedure help.
  66.  * @author: The regex for procedure author.
  67.  * @copyright: The regex for procedure copyright.
  68.  * @date: The regex for procedure date.
  69.  * @proc_type: The regex for procedure type: { 'Internal GIMP procedure', 'GIMP Plug-in', 'GIMP Extension' }.
  70.  * @num_matches: The number of matching procedures.
  71.  * @procedure_names: The list of procedure names.
  72.  *
  73.  * Queries the procedural database for its contents using regular
  74.  * expression matching.
  75.  *
  76.  * This procedure queries the contents of the procedural database. It
  77.  * is supplied with seven arguments matching procedures on { name,
  78.  * blurb, help, author, copyright, date, procedure type}. This is
  79.  * accomplished using regular expression matching. For instance, to
  80.  * find all procedures with \"jpeg\" listed in the blurb, all seven
  81.  * arguments can be supplied as \".*\", except for the second, which
  82.  * can be supplied as \".*jpeg.*\". There are two return arguments for
  83.  * this procedure. The first is the number of procedures matching the
  84.  * query. The second is a concatenated list of procedure names
  85.  * corresponding to those matching the query. If no matching entries
  86.  * are found, then the returned string is NULL and the number of
  87.  * entries is 0.
  88.  *
  89.  * Returns: TRUE on success.
  90.  */
  91. gboolean
  92. gimp_procedural_db_query (gchar   *name,
  93.               gchar   *blurb,
  94.               gchar   *help,
  95.               gchar   *author,
  96.               gchar   *copyright,
  97.               gchar   *date,
  98.               gchar   *proc_type,
  99.               gint    *num_matches,
  100.               gchar ***procedure_names)
  101. {
  102.   GimpParam *return_vals;
  103.   gint nreturn_vals;
  104.   gboolean success = TRUE;
  105.   gint i;
  106.  
  107.   return_vals = gimp_run_procedure ("gimp_procedural_db_query",
  108.                     &nreturn_vals,
  109.                     GIMP_PDB_STRING, name,
  110.                     GIMP_PDB_STRING, blurb,
  111.                     GIMP_PDB_STRING, help,
  112.                     GIMP_PDB_STRING, author,
  113.                     GIMP_PDB_STRING, copyright,
  114.                     GIMP_PDB_STRING, date,
  115.                     GIMP_PDB_STRING, proc_type,
  116.                     GIMP_PDB_END);
  117.  
  118.   *num_matches = 0;
  119.   *procedure_names = NULL;
  120.  
  121.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  122.  
  123.   if (success)
  124.     {
  125.       *num_matches = return_vals[1].data.d_int32;
  126.       *procedure_names = g_new (gchar *, *num_matches);
  127.       for (i = 0; i < *num_matches; i++)
  128.     (*procedure_names)[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
  129.     }
  130.  
  131.   gimp_destroy_params (return_vals, nreturn_vals);
  132.  
  133.   return success;
  134. }
  135.  
  136. /**
  137.  * _gimp_procedural_db_proc_info:
  138.  * @procedure: The procedure name.
  139.  * @blurb: A short blurb.
  140.  * @help: Detailed procedure help.
  141.  * @author: Author(s) of the procedure.
  142.  * @copyright: The copyright.
  143.  * @date: Copyright date.
  144.  * @proc_type: The procedure type.
  145.  * @num_args: The number of input arguments.
  146.  * @num_values: The number of return values.
  147.  *
  148.  * Queries the procedural database for information on the specified
  149.  * procedure.
  150.  *
  151.  * This procedure returns information on the specified procedure. A
  152.  * short blurb, detailed help, author(s), copyright information,
  153.  * procedure type, number of input, and number of return values are
  154.  * returned. For specific information on each input argument and return
  155.  * value, use the 'gimp_procedural_db_proc_arg' and
  156.  * 'gimp_procedural_db_proc_val' procedures.
  157.  *
  158.  * Returns: TRUE on success.
  159.  */
  160. gboolean
  161. _gimp_procedural_db_proc_info (gchar            *procedure,
  162.                    gchar           **blurb,
  163.                    gchar           **help,
  164.                    gchar           **author,
  165.                    gchar           **copyright,
  166.                    gchar           **date,
  167.                    GimpPDBProcType  *proc_type,
  168.                    gint             *num_args,
  169.                    gint             *num_values)
  170. {
  171.   GimpParam *return_vals;
  172.   gint nreturn_vals;
  173.   gboolean success = TRUE;
  174.  
  175.   return_vals = gimp_run_procedure ("gimp_procedural_db_proc_info",
  176.                     &nreturn_vals,
  177.                     GIMP_PDB_STRING, procedure,
  178.                     GIMP_PDB_END);
  179.  
  180.   *blurb = NULL;
  181.   *help = NULL;
  182.   *author = NULL;
  183.   *copyright = NULL;
  184.   *date = NULL;
  185.   *proc_type = 0;
  186.   *num_args = 0;
  187.   *num_values = 0;
  188.  
  189.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  190.  
  191.   if (success)
  192.     {
  193.       *blurb = g_strdup (return_vals[1].data.d_string);
  194.       *help = g_strdup (return_vals[2].data.d_string);
  195.       *author = g_strdup (return_vals[3].data.d_string);
  196.       *copyright = g_strdup (return_vals[4].data.d_string);
  197.       *date = g_strdup (return_vals[5].data.d_string);
  198.       *proc_type = return_vals[6].data.d_int32;
  199.       *num_args = return_vals[7].data.d_int32;
  200.       *num_values = return_vals[8].data.d_int32;
  201.     }
  202.  
  203.   gimp_destroy_params (return_vals, nreturn_vals);
  204.  
  205.   return success;
  206. }
  207.  
  208. /**
  209.  * gimp_procedural_db_proc_arg:
  210.  * @procedure: The procedure name.
  211.  * @arg_num: The argument number.
  212.  * @arg_type: The type of argument.
  213.  * @arg_name: The name of the argument.
  214.  * @arg_desc: A description of the argument.
  215.  *
  216.  * Queries the procedural database for information on the specified
  217.  * procedure's argument.
  218.  *
  219.  * This procedure returns information on the specified procedure's
  220.  * argument. The argument type, name, and a description are retrieved.
  221.  *
  222.  * Returns: TRUE on success.
  223.  */
  224. gboolean
  225. gimp_procedural_db_proc_arg (gchar           *procedure,
  226.                  gint             arg_num,
  227.                  GimpPDBArgType  *arg_type,
  228.                  gchar          **arg_name,
  229.                  gchar          **arg_desc)
  230. {
  231.   GimpParam *return_vals;
  232.   gint nreturn_vals;
  233.   gboolean success = TRUE;
  234.  
  235.   return_vals = gimp_run_procedure ("gimp_procedural_db_proc_arg",
  236.                     &nreturn_vals,
  237.                     GIMP_PDB_STRING, procedure,
  238.                     GIMP_PDB_INT32, arg_num,
  239.                     GIMP_PDB_END);
  240.  
  241.   *arg_type = 0;
  242.   *arg_name = NULL;
  243.   *arg_desc = NULL;
  244.  
  245.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  246.  
  247.   if (success)
  248.     {
  249.       *arg_type = return_vals[1].data.d_int32;
  250.       *arg_name = g_strdup (return_vals[2].data.d_string);
  251.       *arg_desc = g_strdup (return_vals[3].data.d_string);
  252.     }
  253.  
  254.   gimp_destroy_params (return_vals, nreturn_vals);
  255.  
  256.   return success;
  257. }
  258.  
  259. /**
  260.  * gimp_procedural_db_proc_val:
  261.  * @procedure: The procedure name.
  262.  * @val_num: The return value number.
  263.  * @val_type: The type of return value.
  264.  * @val_name: The name of the return value.
  265.  * @val_desc: A description of the return value.
  266.  *
  267.  * Queries the procedural database for information on the specified
  268.  * procedure's return value.
  269.  *
  270.  * This procedure returns information on the specified procedure's
  271.  * return value. The return value type, name, and a description are
  272.  * retrieved.
  273.  *
  274.  * Returns: TRUE on success.
  275.  */
  276. gboolean
  277. gimp_procedural_db_proc_val (gchar           *procedure,
  278.                  gint             val_num,
  279.                  GimpPDBArgType  *val_type,
  280.                  gchar          **val_name,
  281.                  gchar          **val_desc)
  282. {
  283.   GimpParam *return_vals;
  284.   gint nreturn_vals;
  285.   gboolean success = TRUE;
  286.  
  287.   return_vals = gimp_run_procedure ("gimp_procedural_db_proc_val",
  288.                     &nreturn_vals,
  289.                     GIMP_PDB_STRING, procedure,
  290.                     GIMP_PDB_INT32, val_num,
  291.                     GIMP_PDB_END);
  292.  
  293.   *val_type = 0;
  294.   *val_name = NULL;
  295.   *val_desc = NULL;
  296.  
  297.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  298.  
  299.   if (success)
  300.     {
  301.       *val_type = return_vals[1].data.d_int32;
  302.       *val_name = g_strdup (return_vals[2].data.d_string);
  303.       *val_desc = g_strdup (return_vals[3].data.d_string);
  304.     }
  305.  
  306.   gimp_destroy_params (return_vals, nreturn_vals);
  307.  
  308.   return success;
  309. }
  310.  
  311. /**
  312.  * _gimp_procedural_db_get_data:
  313.  * @identifier: The identifier associated with data.
  314.  * @bytes: The number of bytes in the data.
  315.  * @data: A byte array containing data.
  316.  *
  317.  * Returns data associated with the specified identifier.
  318.  *
  319.  * This procedure returns any data which may have been associated with
  320.  * the specified identifier. The data is a variable length array of
  321.  * bytes. If no data has been associated with the identifier, an error
  322.  * is returned.
  323.  *
  324.  * Returns: TRUE on success.
  325.  */
  326. gboolean
  327. _gimp_procedural_db_get_data (gchar   *identifier,
  328.                   gint    *bytes,
  329.                   guint8 **data)
  330. {
  331.   GimpParam *return_vals;
  332.   gint nreturn_vals;
  333.   gboolean success = TRUE;
  334.  
  335.   return_vals = gimp_run_procedure ("gimp_procedural_db_get_data",
  336.                     &nreturn_vals,
  337.                     GIMP_PDB_STRING, identifier,
  338.                     GIMP_PDB_END);
  339.  
  340.   *bytes = 0;
  341.   *data = NULL;
  342.  
  343.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  344.  
  345.   if (success)
  346.     {
  347.       *bytes = return_vals[1].data.d_int32;
  348.       *data = g_new (guint8, *bytes);
  349.       memcpy (*data, return_vals[2].data.d_int8array,
  350.           *bytes * sizeof (guint8));
  351.     }
  352.  
  353.   gimp_destroy_params (return_vals, nreturn_vals);
  354.  
  355.   return success;
  356. }
  357.  
  358. /**
  359.  * gimp_procedural_db_get_data_size:
  360.  * @identifier: The identifier associated with data.
  361.  *
  362.  * Returns size of data associated with the specified identifier.
  363.  *
  364.  * This procedure returns the size of any data which may have been
  365.  * associated with the specified identifier. If no data has been
  366.  * associated with the identifier, an error is returned.
  367.  *
  368.  * Returns: The number of bytes in the data.
  369.  */
  370. gint
  371. gimp_procedural_db_get_data_size (gchar *identifier)
  372. {
  373.   GimpParam *return_vals;
  374.   gint nreturn_vals;
  375.   gint bytes = 0;
  376.  
  377.   return_vals = gimp_run_procedure ("gimp_procedural_db_get_data_size",
  378.                     &nreturn_vals,
  379.                     GIMP_PDB_STRING, identifier,
  380.                     GIMP_PDB_END);
  381.  
  382.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  383.     bytes = return_vals[1].data.d_int32;
  384.  
  385.   gimp_destroy_params (return_vals, nreturn_vals);
  386.  
  387.   return bytes;
  388. }
  389.  
  390. /**
  391.  * _gimp_procedural_db_set_data:
  392.  * @identifier: The identifier associated with data.
  393.  * @bytes: The number of bytes in the data.
  394.  * @data: A byte array containing data.
  395.  *
  396.  * Associates the specified identifier with the supplied data.
  397.  *
  398.  * This procedure associates the supplied data with the provided
  399.  * identifier. The data may be subsequently retrieved by a call to
  400.  * 'procedural-db-get-data'.
  401.  *
  402.  * Returns: TRUE on success.
  403.  */
  404. gboolean
  405. _gimp_procedural_db_set_data (gchar  *identifier,
  406.                   gint    bytes,
  407.                   guint8 *data)
  408. {
  409.   GimpParam *return_vals;
  410.   gint nreturn_vals;
  411.   gboolean success = TRUE;
  412.  
  413.   return_vals = gimp_run_procedure ("gimp_procedural_db_set_data",
  414.                     &nreturn_vals,
  415.                     GIMP_PDB_STRING, identifier,
  416.                     GIMP_PDB_INT32, bytes,
  417.                     GIMP_PDB_INT8ARRAY, data,
  418.                     GIMP_PDB_END);
  419.  
  420.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  421.  
  422.   gimp_destroy_params (return_vals, nreturn_vals);
  423.  
  424.   return success;
  425. }
  426.